package com.wondersgroup.core.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wondersgroup.core.mapper.ProductMapper;
import com.wondersgroup.core.mapper.ProductPlatformMapper;
import com.wondersgroup.core.resultmap.DTOProduct;

@Service
public class ProductInfoService {
	@Autowired
	private ProductMapper productMapper;
	
	@Autowired
	private ProductPlatformMapper productPlatformMapper;

	public DTOProduct findProductByBarcode(String barcode) {
		DTOProduct dtoProduct = productMapper.findByBarcode(barcode);
		List<Map<Object,Object>> companyInfo = findCompanyByBarcode(barcode);
		dtoProduct.setCompanyInfo(companyInfo);
		return dtoProduct;

	}
	
	//在ProductPlatform里面，通过barcode查询company
	public List<Map<Object,Object>> findCompanyByBarcode(String barcode) {
		List<Map<Object,Object>> findCompanyByBarcode = productPlatformMapper.findCompanyByBarcode(barcode);
		return findCompanyByBarcode;
	}
	
}

